<template>
  <div class="app-container">
    <search-box
      :fields="searchFeilds"
      @search="handleSearch"
      @add="handleAdd"
    />


    <SearchResult
      uid="banner"
      ref="searchResult"
      :params="params"
      :ignoreCommand="ignoreCommand"
    >
      <el-table-column label="Banner 类型" align="left">
        <template slot-scope="{row}">
          <span>{{ row.bannerType }}</span>
        </template>
      </el-table-column>
      <el-table-column label="请求来源" align="left">
        <template slot-scope="{row}">
          <span>{{ requestSourceMap[row.requestSource] }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否启用" align="center">
        <template slot-scope="{row}">
          <span>{{ row.isEnable === 1 ? '是' : '否' }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="Banner" align="center">
        <template slot-scope="{row}">
          <cImage style="width: 48px; height: 48px" :imageId="row.bannerFileId" fit="contain"></cImage>
        </template>
      </el-table-column> -->
    </SearchResult>
  </div>
</template>
<script>
import SearchBox from '@/components/SearchBox';
import SearchResult from '@/components/SearchResult';
import { isEnableOptions, requestSourceMap, requestSourceOptions } from '@/utils/config';
import cImage from '@/components/Image';

export default {
  name: 'banner',
  components: { SearchBox, SearchResult, cImage },
  data() {
    return {
      searchFeilds: [
        { name: 'BannerType', label: 'Banner类型', type: 'text' },
        { name: 'IsEnable', label: '是否启用', type: 'list', options: isEnableOptions },
        { name: 'RequestSource', label: '请求来源', type: 'list', options: requestSourceOptions }
      ],
      ignoreCommand: ['detail'],
      params: {},
      requestSourceMap
    };
  },

  methods: {
    // 搜索
    handleSearch(data) {
      if (data === void 0) data = {};

      this.params = data;
      this.$refs['searchResult'].getData(data);
    },

    // 添加
    handleAdd() {
      this.$refs['searchResult'].handleAdd();
    }
  }
}
</script>
